home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
bc_ti
/
ti644.asc
< prev
next >
Wrap
Text File
|
1992-02-24
|
2KB
|
67 lines
PRODUCT : Borland C++ NUMBER : 644
VERSION : All
OS : PC DOS
DATE : February 25, 1992 PAGE : 1/1
TITLE : Windows DLL and Fatal Exit Code=0x001A
Fatal Exit Code=0x001A is not documented by the SDK but what it
seems to mean is that an attempt has been made to FreeLibrary() a
DLL which has registered a GLOBALCLASS window class still in use
by another open window.
For example, a window class with the style CS_GLOBALCLASS is
registered in order to make a custom control (like "button",
"checkbox", etc.). In the main program, a LoadLibrary() and a
CreateWindow() are executed to create a child window of that
custom class.
In a WM_DESTROY message handler, a FreeLibrary() is done followed
by a PostQuitMessage(0). Seems like a reasonable procedure but
results in a Fatal Exit Code=0x001A from Windows when the DLL is
used. Puzzled?
A careful reading of the SDK reference indicates that WM_DESTROY
is sent to a parent window BEFORE its children are destroyed.
The library freed from memory by the FreeLibrary() call contained
the necessary class information for the child window. Since this
is all happening inside of a WM_DESTROY handler, this child
window isn't closed yet and the result is the Fatal Exit
Code=0x001A.
One solution is to trap WM_CLOSE and close the affected windows
prior to the FreeLibrary() call:
case WM_CLOSE:
DestroyWindow(handle of main window);
DestroyWindow(handle of first child window);
DestroyWindow(handle of second child window);
:
:
FreeLibrary(library handle);
break;
This effectively forces Windows to close all of the children
BEFORE freeing the library that they are based on.